package learn_effective_java.item_03;

import java.lang.reflect.AccessibleObject;
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;

public class Client {
	
	public static void main(String[] args) throws IllegalArgumentException, IllegalAccessException, InstantiationException, InvocationTargetException, NoSuchFieldException, SecurityException {
		Elvis1 elvis1 = Elvis1.INSTANCE;
		elvis1.leaveTheBuilding();
		
//		Field[] fields = elvis1.getClass().getDeclaredFields();
		Constructor<?>[] constructors = elvis1.getClass().getDeclaredConstructors();
		
//		AccessibleObject.setAccessible(fields, true);
		AccessibleObject.setAccessible(constructors, true);
		
//		Field field1 = elvis1.getClass().getDeclaredField("exist");
//		boolean v = field1.getBoolean(elvis1);
//		System.out.println(v);
		
		Elvis1 newInstance = (Elvis1) constructors[0].newInstance(new Object[] {});
		newInstance.leaveTheBuilding();
		
	}

}
